home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / DOCZ16.ZIP;1 / DOCZ.LIF / JULDATE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-24  |  1.7 KB  |  66 lines

  1. #ifdef DOCUMENTATION
  2. /******************************* DOCZ Header *********************************
  3. .MODULE                juldate
  4. .LIBRARY             csub
  5. .TYPE                 function
  6. .APPLICATION        date/time
  7. .SYSTEM                msdos-s
  8. .SYSTEM                msdos-l
  9. .SYSTEM                vms
  10. .SYSTEM                unix
  11. .AUTHOR                Software Toolz
  12. .LANGUAGE            C
  13. .DESCRIPTION
  14.     Calendar to integer julian conversion
  15. .ARGUMENTS
  16.     unsigned short juldate(year,month,day)
  17.         unsigned year,             /* (r) 1 - 99 */
  18.                     month,            /* (r) 1 - 12 */
  19.                     day;                /* (r) 1 - 31 */
  20. .NARRATIVE
  21.     enter year    = 1 to 99 for 1901 to 1999
  22.             month   = 1  to 12
  23.             day     = 1    to 31
  24. .RETURNS
  25.     The Julian date as an unsigned integer
  26. .SEE_ALSO             jultostr()
  27.     strtojul()
  28.     strtime()
  29.     strdate()
  30. .FIXES                 2/9/89
  31.     Return was "unsigned", now is "unsigned short"
  32. .NOTICE
  33.     Copyright 1989 Software Toolz, Inc. - Atlanta, Georgia
  34.  
  35.     All rights reserved worldwide.  This program may not be reproduced,
  36.     transmitted, transcribed, stored in a retrieval system or translated in 
  37.     any human or computer language, in any form without the express written 
  38.     permission of Software Toolz, Inc.
  39. .ENDOC                 END DOCUMENTATION
  40. *****************************************************************************/
  41. #endif      /* DOCUMENTATION */
  42.  
  43. #include <stdio.h>
  44. #include "csub.h"
  45.  
  46. /*****************************************************************************
  47.     Juldate
  48. *****************************************************************************/
  49. unsigned short juldate(year,month,day)
  50.     unsigned year,             /* (r) 0 - 99 */
  51.                 month,            /* (r) 1 - 12 */
  52.                 day;                /* (r) 1 - 31 */
  53. {
  54.     unsigned int y,m;
  55.  
  56.     y = year;
  57.     if(month > 2)
  58.         m = month - 3;
  59.     else
  60.     {
  61.         m = month + 9;
  62.         y -= 1;
  63.     }
  64.     return((unsigned short)((1461L * y)/4) + (((((153 * m)+2)/5)+day)-1));
  65. }
  66.